package com.xfatm.simplebrowser.ui;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Switch;
import android.widget.TextView;

import com.xfatm.simplebrowser.MainActivity;
import com.xfatm.simplebrowser.R;
import com.xfatm.simplebrowser.entity.BrowserSetting;
import com.xfatm.simplebrowser.util.ActivityManageUtils;
import com.xfatm.simplebrowser.util.SharedPreferencesUtils;

public class SettingActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
    }

    private void initView(){
        //设置标题和返回按钮
        ((TextView)findViewById(R.id.titleName)).setText("设置");
        ((Button)findViewById(R.id.titleBack)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //v.getContext().startActivity(new Intent(v.getContext(), MainActivity.class));
                ActivityManageUtils.finishActivity(ActivityManageUtils.getTopActivity());
            }
        });

        //是否自动隐藏地址栏
        final Switch isAutoHideHead=findViewById(R.id.isAutoHideHead);
        isAutoHideHead.setChecked(BrowserSetting.getSetting().isAutoHideHead());
        isAutoHideHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BrowserSetting.getSetting().setAutoHideHead(isAutoHideHead.isChecked());
            }
        });

    }
}
